package com.ego.coupon.controller;

import java.util.Arrays;

import com.ego.coupon.vo.SkuReductionVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.ego.coupon.po.SkuFullReduction;
import com.ego.coupon.service.SkuFullReductionService;
import com.ego.common.util.Result;

import javax.validation.Valid;

/**
 * @program: ego
 * @description 商品满减信息控制器
 * @author KamTang
 * @date 2022-11-13 13:17:12
 */
@RestController
@RequestMapping("coupon/sku-full-reduction")
public class SkuFullReductionController {

    @Autowired
    private SkuFullReductionService skuFullReductionService;

    @PostMapping("/save-info")
    public Result saveSkuReduction(@Valid @RequestBody SkuReductionVo vo) {
        skuFullReductionService.saveSkuReduction(vo);
        return Result.ok();
    }

    /**
     * 信息
     */
    @GetMapping("/get/{id}")
    public Result get(@PathVariable("id") Long id){
		SkuFullReduction skuFullReduction = skuFullReductionService.getById(id);
        return Result.ok().put("skuFullReduction", skuFullReduction);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public Result save(@RequestBody SkuFullReduction skuFullReduction){
		skuFullReductionService.save(skuFullReduction);
        return Result.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public Result update(@RequestBody SkuFullReduction skuFullReduction){
		skuFullReductionService.updateById(skuFullReduction);
        return Result.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public Result delete(@RequestBody Long[] ids){
		skuFullReductionService.removeByIds(Arrays.asList(ids));
        return Result.ok();
    }

}
